package com.itheima.admin.mapper;


import com.github.pagehelper.IPage;
import com.github.pagehelper.PageInfo;
import com.itheima.admin.dto.UserDto;
import com.itheima.admin.pojo.User;
import com.itheima.admin.vo.RoleUserVo;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

public interface UserMapper {
    @Select("select * from ss_user where user_id = #{id}")
    User selectById(String id);

    @Delete("delete from ss_user where user_id = #{id}")
    boolean deleteById(String id);

    List<User> selectByPage(@Param("state") String status, @Param("username") String username);

    @Insert("insert into ss_user (email,password,user_name,dept_id,gender,state,birthday,join_date,telephone) " +
            "value({userDto.email},{userDto.password},{userDto.userName},{userDto.deptId},{userDto.gender},{userDto.state}," +
            "{userDto.birthday},{userDto.joinDate},{userDto.telephone})")
    boolean insertUser(UserDto userDto);

    @Update("Update ss_user set user_id={userDto.userId}," +
            "email={userDto.email}," +
            "password={userDto.password}," +
            "user_name={userDto.userName}," +
            "dept_id={userDto.deptId}," +
            "gender={userDto.gender}," +
            "state={userDto.state}," +
            "birthday={userDto.birthday}," +
            "join_date={userDto.joinDate}," +
            "telephone={userDto.telephone}")
    boolean updateUser(UserDto userDto);

    Boolean addUserRole(@Param("roleUserVo") RoleUserVo roleUserVo);
}
